//
//  XMChooseHeadTipView.m
//  XunMi
//
//  Created by MacBook on 2024/2/22.
//  Copyright © 2024 TieZhu. All rights reserved.
//

#import "XMChooseHeadTipView.h"

@interface XMChooseHeadTipView ()
@property (weak, nonatomic) IBOutlet UIView *bottomBgV;

@property (nonatomic, copy) void(^takeBlock)(void);
@property (nonatomic, copy) void(^chooseBlock)(void);
@property (nonatomic, copy) void(^cancelBlock)(void);

@end

@implementation XMChooseHeadTipView

- (void)layoutSubviews {
    [super layoutSubviews];
    // 设置左上和右上角为圆角
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bottomBgV.bounds
                                                   byRoundingCorners:(UIRectCornerTopLeft | UIRectCornerTopRight)
                                                         cornerRadii:CGSizeMake(20.0, 20.0)];
    
    CAShapeLayer *maskLayer = [CAShapeLayer layer];
    maskLayer.frame = self.bottomBgV.bounds;
    maskLayer.path = maskPath.CGPath;
    self.bottomBgV.layer.mask = maskLayer;
    
}

- (IBAction)takeAct:(UIButton *)sender {
    if (self.takeBlock) {
        self.takeBlock();
    }
}

- (IBAction)chooseAct:(UIButton *)sender {
    if (self.chooseBlock) {
        self.chooseBlock();
    }
}

- (IBAction)cancelAct:(UIButton *)sender {
    if (self.cancelBlock) {
        self.cancelBlock();
    }
}

- (void)actionTakeBlock:(void(^)(void))takeBlock
            chooseBlock:(void(^)(void))chooseBlock
            cancelBlock:(void(^)(void))cancelBlock {
    _takeBlock = takeBlock;
    _chooseBlock = chooseBlock;
    _cancelBlock = cancelBlock;
}

@end
